<template>
  <div id="app">
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive"></router-view>
    <div style="height: 3.8rem"></div>
    <van-tabbar v-model="active" safe-area-inset-bottom @change="onChange">
      <van-tabbar-item replace to="/" icon="home-o">首页</van-tabbar-item>
      <van-tabbar-item replace to="/redirect" icon="user-o"
        >我的案件</van-tabbar-item
      >
    </van-tabbar>
  </div>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
export default {
  name: "app",
  data() {
    return {
      transitionName: "slide-right",
      active: 0,
    };
  },
  computed: {
    ...mapGetters(["tabBarActive"]),
  },
  created() {
    this.active = this.tabBarActive;
  },
  methods: {
    ...mapActions(["setTabBarActive"]),
    onChange(active) {
      // console.log(active);
      this.setTabBarActive(active);
    },
  },
};
</script>

<style>
#app .van-tabbar {
  border-top: 1px solid #f5f5f5;
}
</style>
